package com.electricaalberti.connection.bd;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

import javax.swing.JOptionPane;

public class ConnectionBaseDades {
	
	private String incorrectConection ="Error al establecer la conexion con la base de datos";
	private String titleIncorrectCon = "Error de conexion";
	
	private String errorDriver = "Error al iontentar conectar con el driver MySQL";
	private String titleDriver = "Error Driver";
	
	public Connection Conexion(){
		Connection con = null;
		
		try{
			Class.forName("com.mysql.jdbc.Driver");
			con = DriverManager.getConnection("jdbc:mysql://localhost:3306/almacen_electrica_alberti","root","78217369-E");
		}catch(SQLException e){
			JOptionPane.showMessageDialog(null, incorrectConection, titleIncorrectCon, JOptionPane.ERROR_MESSAGE);
		}catch(ClassNotFoundException e){
			JOptionPane.showMessageDialog(null, errorDriver, titleDriver, JOptionPane.ERROR_MESSAGE);
		}
		
		return con;
		
	}

}
